package com.example.jdk11test.controller;

import ch.qos.logback.core.util.TimeUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

/**
 * @program: jdk11test
 * @description:
 * @author: Jiliang.Lee
 * @create: 2019-08-30 10:11
 **/
@RestController
@Slf4j
public class TestController {

	@GetMapping("/mono")
	public Mono<String> monoTest() {
		log.info("start-------------");
		Mono<String> stringMono = Mono.fromSupplier(this::doSomeThing);
		log.info("end-------------");
		return stringMono;
	}

	private String doSomeThing() {
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return "任务完成";
	}

}
